﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NasuTek.Shion.Extencibility
{
    /// <summary>
    /// This class is used for creating Shion Themes.
    /// </summary>
    public class Theme
    {
        /// <summary>
        /// Gets the Style sheet for the theme
        /// </summary>
        /// <returns>CSS Information</returns>
        public virtual string[] GetStyleSheet()
        {
            return new string[] {
            ".normal { color: white; background-color: black; }",
            "body { color: white; background-color: black; margin: 0 0 0 0; font-family:\"Verdana\"; font-size:12px }",
            "div.modechange, div.join, div.part, div.echo, div.topicchanged, div.nickchange, div.unbanned { color: green; }",
            "div.quit { color: blue; }",
            "div.highlight { background-color: #FFD700; color: black; }",
            "div.action, div.ownaction { color: purple; }",
            "div.kicked, div.banned, div.error { background-color: red; }",
            };
        }

        /// <summary>
        /// Parses a Shion Data Array to HTML
        /// </summary>
        /// <param name="data">The Client's Sender Information to be parsed</param>
        /// <returns>Parsed HTML</returns>
        public string ParseData(string[] data)
        {
            //The Return HTML - Set this to the HTML Text to return to the parser
            string returnvalue = String.Join("{", data);

            //======================================================================
            //message = Returned if its a message
            //{0} = Nickname of Sender
            //{1} = Message
            //======================================================================
            if (data[0] == "message") { returnvalue = String.Format("[{2}] &lt;{0}&gt; {1}", data[1], data[2], data[3]); }

            //======================================================================
            //ownmessage = Returned if its a message from yourself
            //{0} = Your Nickname
            //{1} = Message
            //======================================================================
            if (data[0] == "ownmessage") { returnvalue = String.Format("[{2}] &lt;{0}&gt; {1}", data[1], data[2], data[3]); }


            //======================================================================
            //ownaction = Returned if its a action
            //{0} = Nickname of Sender
            //{1} = Message
            //======================================================================
            else if (data[0] == "ownaction") { returnvalue = String.Format("[{2}] * {0} {1}", data[1], data[2], data[3]); }

            //======================================================================
            //action = Returned if its a action
            //{0} = Nickname of Sender
            //{1} = Message
            //======================================================================
            else if (data[0] == "action") { returnvalue = String.Format("[{2}] * {0} {1}", data[1], data[2], data[3]); }

            //======================================================================
            //notice = Returned if its a notice
            //{0} = Nickname of Sender
            //{1} = Message
            //======================================================================
            else if (data[0] == "notice") { returnvalue = String.Format("[{2}] -{0}- {1}", data[1], data[2], data[3]); }

            //======================================================================
            //ownnotice = Returned if its a notice
            //{0} = Nickname of Sender
            //{1} = Message
            //======================================================================
            else if (data[0] == "ownnotice") { returnvalue = String.Format("[{2}] -{0}- {1}", data[1], data[2], data[3]); }

            //======================================================================
            //join = Join Channel
            //{0} = Nick
            //{1} = Channel
            //{2} = Hostmask
            //======================================================================
            else if (data[0] == "join") { returnvalue = String.Format("[{3}] * {0} ({2}) joined channel {1}", new object[] { data[1], data[2], data[3], data[4] }); }

            //======================================================================
            //part = Part Channel
            //{0} = Nick
            //{1} = Channel
            //======================================================================
            else if (data[0] == "part") { returnvalue = String.Format("[{2}] * {0} parted channel {1}", data[1], data[2], data[3]); }

            //======================================================================
            //nickchange = called on nick change
            //{0} = Old Nick
            //{1} = New Nick
            //======================================================================
            else if (data[0] == "nickchange") { returnvalue = String.Format("[{2}] * {0} changed nick to {1}", data[1], data[2], data[3]); }

            //======================================================================
            //topicchanged = Returned if its a topic change
            //{0} = Nick
            //{1} = Message
            //======================================================================
            else if (data[0] == "topicchanged") { returnvalue = String.Format("[{2}] * {0} changed topic to: {1}", data[1], data[2], data[3]); }

            //======================================================================
            //echo = Message Echo
            //{0} = Message
            //======================================================================
            else if (data[0] == "echo") { returnvalue = String.Format("[{1}] {0}", data[1], data[2]); }

            //======================================================================
            //quit = Quit
            //{0} = User
            //{1} = Message
            //{2} = Hostmask
            //======================================================================
            else if (data[0] == "quit") { returnvalue = String.Format("[{3}] * {0} ({2}) Quit IRC ({1})", new object[] { data[1], data[2], data[3], data[4] }); }

            //======================================================================
            //error = Message Error
            //{0} = Message
            //======================================================================
            else if (data[0] == "error") { returnvalue = String.Format("[{1}] <strong>IRC ERROR</strong> {0}", data[1], data[2]); }

            //======================================================================
            //kicked = User Kicked
            //{0} = Nick of Who kicked
            //{1} = Nick of Whom kicked
            //{2} = Reason
            //======================================================================
            else if (data[0] == "kicked") { returnvalue = String.Format("[{3}] * {1} was kicked by {0} ({2})", new object[] { data[1], data[2], data[3], data[4] }); }

            //======================================================================
            //banned = User Banned
            //{0} = Who
            //{1} = Hostmask Banned
            //======================================================================
            else if (data[0] == "banned") { returnvalue = String.Format("[{2}] * {0} banned hostmask {1}", data[1], data[2], data[3]); }

            //======================================================================
            //unbanned = User Unbanned
            //{0} = Who
            //{1} = Hostmask Banned
            //======================================================================
            else if (data[0] == "unbanned") { returnvalue = String.Format("[{2}] * {0} unbanned hostmask {1}", data[1], data[2], data[3]); }

            //======================================================================
            //modechange = User Mode Change
            //{0} = Who
            //{1} = Mode
            //======================================================================
            else if (data[0] == "modechange") { returnvalue = String.Format("[{2}] * {0} Changed mode to {1}", data[1], data[2], data[3]); }

            return returnvalue;
        }
    }
}
